﻿using System;
using System.Collections.Generic;
using Enterprise.Framework.Core.Container;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Resto.CostControl.Core.Facade.DishModule.DataTransferObject;
using Resto.CostControl.Core.Facade.DishModule.FacadeObject;

namespace Resto.CostControl.UnitTest.DishModule
{


    /// <summary>
    ///这是 DishFOTest 的测试类，旨在
    ///包含所有 DishFOTest 单元测试
    ///</summary>
    [TestClass()]
    public class WeekDishFOTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region 附加测试特性
        // 
        //编写测试时，还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///AddDish 的测试
        ///</summary>
        [TestMethod()]
        public void AddWeekDishTest()
        {
            DishFO target = ObjectCreator.Create<DishFO>();
            WeekDishDTO dishDTO = new WeekDishDTO()
            {
                BeginDate = DateTime.Now,
                EndDate = DateTime.Now.AddDays(7),
            };

            DishDTO dish1 = target.GetDishDTO("1");
            DishDTO dish2 = target.GetDishDTO("2");

            List<DishDTO> list = new List<DishDTO>();
            list.Add(dish1);
            list.Add(dish2);

            dishDTO.Items = list.ToArray();

            WeekDishFO weekDishFO = ObjectCreator.Create<WeekDishFO>();
            weekDishFO.AddWeekDish(dishDTO);

        }

        [TestMethod]
        public void UpdateDishTest()
        {
            WeekDishFO weekDishFO = ObjectCreator.Create<WeekDishFO>();
            WeekDishDTO dishDTO = weekDishFO.GetWeekDishDTO(DateTime.Now.AddDays(1));

            if (dishDTO != null)
            {
                DishFO target = ObjectCreator.Create<DishFO>();
                DishDTO dish1 = target.GetDishDTO(3);
                DishDTO dish2 = target.GetDishDTO(4);

                List<DishDTO> list = new List<DishDTO>();
                list.Add(dish1);
                list.Add(dish2);

                dishDTO.Items = list.ToArray();
            }

            weekDishFO.UpdateWeekDish(dishDTO);

        }
    }
}
